home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / smallc.arc / _MAIN.C next >
Text File  |  1985-07-17  |  2KB  |  56 lines

  1.  
  2. /** m20.c  --  defines _main for DOS 2.0   6.15.83
  3. *
  4. * This module defines a version of _main which processes the
  5. * command line for arguments and sets up _iob so that the first
  6. * three files defined are stdin, stdout, stderr which are opened
  7. * by DOS 2.0.  Re-direction is supported via DOS.
  8. * Stack size override is not supported.
  9. *
  10. *                       Ted Reuss     c/o South Texas Software, Inc.
  11. *                 Home: 713/961-3926      4544 Post Oak Place, Suite 176
  12. *                 Offi: 713/877-8205      Houston, Tx 77027
  13. *
  14. **/
  15. #include <stdio.h>
  16. #define STDIN  0
  17. #define STDOUT 1
  18. #define STDERR 2
  19. #define MAXARG 32               /* maximum command line arguments */
  20.  
  21. _main(line)
  22. char *line;
  23. {
  24. static int argc = 0;
  25. static char *argv[MAXARG];
  26.  
  27. while (isspace(*line)) line++;  /* find program name */
  28. while (*line != '\0' && argc < MAXARG)
  29.    {                    /* get command line parameters */
  30.    argv[argc++] = line;
  31.    while (*line != '\0' && isspace(*line) == 0) line++;
  32.    if (*line == '\0') break;
  33.    *line++ = '\0';
  34.    while (isspace(*line)) line++;
  35.    }
  36.  
  37. stdin->_flag |= _IONBF+_IOREAD;
  38. stdin->_file = STDIN;
  39. stdin->_base = stdin->_ptr = getmem(_BUFSIZ);
  40. stdin->_cnt  = 0;
  41.  
  42. stdout->_flag |= _IONBF+_IOWRT;
  43. stdout->_file = STDOUT;
  44. stdout->_base = stdout->_ptr = getmem(_BUFSIZ);
  45. stdout->_cnt  = 0;
  46.  
  47. stderr->_flag |= _IONBF+_IOWRT;
  48. stderr->_file = STDERR;
  49. stderr->_base = stderr->_ptr = getmem(_BUFSIZ);
  50. stderr->_cnt  = 0;
  51.  
  52. main(argc, argv);       /* call main function */
  53. }
  54. /** END M20 **/
  55.  
  56.